package cate.game.fight.msg;

import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgOutput;
import cate.game.client.msg.id.MsgIdBFight;
import cate.game.fight.task.FightTask;
import cate.game.play.proce.play.PlayPO;
import cate.game.play.vo.PlayVO;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "战斗剧本 の 返回")
public class FightPlayResp implements MsgOutput{

    @NoteField("功能id")
    public int funcId;

    @NoteField(value = "剧本")
    public PlayVO play;


    public FightPlayResp(int funcId, PlayPO play) {
        this.funcId = funcId;
        this.play = new PlayVO().read(play);
    }

    public FightPlayResp() {
    }

    public static void sendWhenFighting(Role role, int funcId) {
        FightTask task = role.getGame().fight.task.getTask(role, funcId);
        if (task != null && !task.invalid()) {
            // 某些剧本不需要下发
            if (task.play != null && task.context.needSend) {
                FightPlayResp resp = new FightPlayResp();
                resp.funcId = funcId;
                resp.play = new PlayVO().read(task.play);
                role.sendNow(resp);
            }
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBFight.PLAY_RESP;
    }
}
